# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=threat-dragon
pkgver=2.2.0
pkgrel=1
pkgdesc='Electron Threat Modelling and diagramming tool.'
groups=('blackarch' 'blackarch-threat-model')
arch=('x86_64')
url='https://owasp.org/www-project-threat-dragon/'
license=('Apache-2.0')
depends=('alsa-lib' 'cairo' 'gtk3' 'hicolor-icon-theme' 'libxkbcommon' 'nspr'
         'nss' 'pango')
options=(!debug)
source=("https://github.com/OWASP/threat-dragon/releases/download/v$pkgver/${pkgname}_${pkgver}_amd64.deb")
sha512sums=('9bb7d1e62adff564fc21e64262e566696c7e41dd9d0596faf299666f50884444aa787113188da4a12d62b69e8676e4b492d6fffe684c798937508bb45253f091')


package() {
  install -dm 755 "$pkgdir/usr/bin"

  tar -xf data.tar.xz -C "$pkgdir"

  # fix icon
  mkdir -p "$pkgdir/usr/share/icons/hicolor/256x256/apps"
  mv "$pkgdir/usr/share/icons/hicolor/0x0/apps/$pkgname.png" \
    "$pkgdir/usr/share/icons/hicolor/256x256/apps/$pkgname.png"
  rm -r "$pkgdir/usr/share/icons/hicolor/0x0"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /opt/Threat-Dragon-ng
exec ./$pkgname "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

